<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui" template="template.xhtml">

	<ui:define name="main">
		<div class="header header_cameras" />
		<h:form id="formConsultaCamera">
			<p:commandButton value="#{msgs.menu_cadastramento_cameras_creche}"
				action="cadastro_camera" ajax="false" />

			<p:dataTable var="camera" value="#{cameraBean.listaCamera}"
				emptyMessage="#{msgs.pesquisa_vazia}#{msgs.dois_pontos}">
				<p:column filterBy="#{camera.idcamera}"
					headerText="#{msgs.numero_camera}#{msgs.dois_pontos}"
					footerText="#{msgs.contem}" filterMatchMode="contains">
					<h:outputText value="#{camera.idcamera}" />
				</p:column>
				<p:column headerText="#{msgs.descricao_camera}#{msgs.dois_pontos}"
					style="width:150px" footerText="#{msgs.comeca_com}"
					filterBy="#{camera.descCamera}">
					<h:outputText value="#{camera.descCamera}" />
				</p:column>
				<p:column headerText="#{msgs.nome_camera}#{msgs.dois_pontos}"
					style="width:150px" footerText="#{msgs.comeca_com}"
					filterBy="#{camera.nomeCamera}">
					<h:outputText value="#{camera.nomeCamera}" />
				</p:column>
				<p:column headerText="#{msgs.alterar}#{msgs.dois_pontos}">
					<p:commandButton image="ui-icon-pencil" title="Alterar"
						update="formCadastroCamera" oncomplete="modalCamera.show()"
						action="#{cameraBean.atualizarDadosCamera}">
						<f:setPropertyActionListener target="#{cameraBean.camera}"
							value="#{camera}" />
					</p:commandButton>
				</p:column>
				<p:column style="width:50px;text-align:center"
					headerText="#{msgs.excluir}#{msgs.dois_pontos}">
					<p:commandButton action="#{cameraBean.excluir}"
						image="ui-icon-close" title="Excluir" update="formConsultaCamera">
						<f:setPropertyActionListener target="#{cameraBean.camera}"
							value="#{camera}" />
					</p:commandButton>
				</p:column>
				<h:messages />
			</p:dataTable>
		</h:form>
		<p:dialog header="#{msgs.cadastro_cameras}" widgetVar="modalCamera"
			modal="true" height="500" width="800" showEffect="highlight">
			<h:form id="formCadastroCamera" prependId="false">
				<p:panel id="painelCadastro" header="#{msgs.dados_camera}"
					styleClass="painelCadastro">
					<h:panelGrid columns="2">
						<h:outputLabel value="#{msgs.nome_camera}#{msgs.dois_pontos}" />
						<p:inputText id="NomeCamera"
							value="#{cameraBean.camera.nomeCamera}" maxlength="45"
							required="true">
							<p:message for="NomeCamera" />
						</p:inputText>
						<h:outputLabel value="#{msgs.descricao_camera}#{msgs.dois_pontos}" />
						<p:inputText id="desc_camera" required="true"
							value="#{cameraBean.camera.descCamera}" maxlength="70" size="70">
							<p:message for="desc_camera" />
						</p:inputText>
						<h:outputLabel value="#{msgs.perfis_camera}#{msgs.dois_pontos}" />
						<p:pickList value="#{cameraBean.perfis}" var="perfil"
							itemValue="#{perfil}" itemLabel="#{perfil.nome}"
							converter="br.com.pirralhos.view.converter.PerfilConverter"
							addLabel="#{msgs.adicionar}"
							addAllLabel="#{msgs.adicionar_todos}"
							removeLabel="#{msgs.remover}" id="painel"
							removeAllLabel="#{msgs.remover_todos}" />
					</h:panelGrid>
				</p:panel>
				<h:inputHidden id="hiddenAlterouCamera"
					value="#{cameraBean.alterou}" />
				<h:panelGrid styleClass="painelBotoes" columns="2">
					<p:commandButton value="#{msgs.botao_gravar}"
						action="#{cameraBean.atualizar}"
						update="formConsultaCamera, formCadastroCamera, painelCadastro"
						oncomplete="if(document.getElementById('hiddenAlterouCamera').value=='true'){modalCamera.hide();}" />
					<p:commandButton value="#{msgs.botao_limpar}"
						action="#{cameraBean.limpar}" update="painelCadastro"
						process="@this" />
				</h:panelGrid>
				<h:panelGrid style="height:100px" columns="2">
				</h:panelGrid>
			</h:form>
		</p:dialog>
	</ui:define>
</ui:composition>
